﻿// Copyright (c) 2014 Jonathan Magnan (http://jonathanmagnan.com/).
// All rights reserved (http://zzzproject.com/sqlbulkcopy-extensions/).
// Licensed under MIT License (MIT) (https://zsqlbulkcopy.codeplex.com/license/).
using System.Collections.Generic;

namespace Z.Net.Extensions
{
    internal partial class SqlBulkOperation
    {
        public void PreLogicSetting()
        {
            if (DataSource is IEnumerable<object>)
            {
                DataSourceAsList = new List<object>((IEnumerable<object>) DataSource);
            }

            ParameterMapping = new Dictionary<string, int>();
            for (int i = 0; i < SqlBulkCopy.ColumnMappings.Count; i++)
            {
                ParameterMapping.Add(SqlBulkCopy.ColumnMappings[i].DestinationColumn, i);
            }
        }
    }
}